package com.hp.entity;

import java.util.*;

public class MenusTreeVo {

    private int id;
    private String text;
    private String state;
    private boolean checked=false;
    private String iconCls;
    private String parentid;
    private Map attributes = new HashMap<>();
    private List<MenusTreeVo> children = new ArrayList<>();

    public MenusTreeVo(Menus m, List<Menus> list){
        this.id=m.getId();
        this.text=m.getMenuname();
        this.state="open";

        //判断是否有这个路径
        for (Menus menus : list) {
            if(menus.getId()==this.id){
                this.checked=true;
                continue;
            }
        }

        List<Menus> menus = m.getMenus();
        if(menus!=null&&!menus.isEmpty()&&menus.size()>0){
            for (Menus mmm : menus) {
                this.children.add(new MenusTreeVo(mmm, list));
            }
        }
    }


    private String getIcon() {
        String str="";
        if(parentid==null||parentid.equals("")){
            str="icon-resources";
        }else{
            str="icon-sys";
        }
        return str;
    }


    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getParentid() {
        return parentid;
    }


    public void setParentid(String parentid) {
        this.parentid = parentid;
    }


    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public boolean isChecked() {
        return checked;
    }

    public void setChecked(boolean checked) {
        this.checked = checked;
    }


    public String getIconCls() {
        return iconCls;
    }


    public void setIconCls(String iconCls) {
        this.iconCls = iconCls;
    }


    public Map getAttributes() {
        return attributes;
    }

    public void setAttributes(Map attributes) {
        this.attributes = attributes;
    }

    public List<MenusTreeVo> getChildren() {
        return children;
    }

    public void setChildren(List<MenusTreeVo> children) {
        this.children = children;
    }


}
